package com.btex.app.pager;

import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.support.v4.content.FileProvider;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.btex.app.Config;
import com.btex.app.OTCActivity;
import com.btex.app.R;
import com.btex.app.TradeActivity;
import com.btex.app.WebActivity;
import com.btex.app.adapter.BiBiListAdapter;
import com.btex.app.adapter.HomePageAdapter;
import com.btex.app.entity.BannerBean;
import com.btex.app.entity.BiBiListInfo;
import com.btex.app.entity.FuturesListInfo;
import com.btex.app.entity.GongGao;
import com.btex.app.entity.NewBiInfo;
import com.btex.app.entity.VersionInfo;
import com.btex.app.tools.CookieTool;
import com.btex.app.tools.GlideImageLoader;
import com.btex.app.tools.PermissionUtils;
import com.btex.app.tools.SharedPreferencesUtil;
import com.btex.app.tools.Tools;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.lidroid.xutils.util.PreferencesCookieStore;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.youth.banner.Banner;
import com.youth.banner.listener.OnBannerListener;

import org.apache.http.client.CookieStore;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;


/**
 * Created by wcx on 16/3/16.
 */
public class FragmentNews extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
    private static final String TAG = "FragmentNews";
    @BindView(R.id.fragment_web_tv)
    TextView mFragmentWebTv;
    Unbinder unbinder;
    @BindView(R.id.jiaoyi_changwai)
    LinearLayout mJiaoyiChangwai;
    @BindView(R.id.fanli)
    LinearLayout mFanli;
    @BindView(R.id.bangzhu_center)
    LinearLayout mBangzhuCenter;
    @BindView(R.id.kefu)
    LinearLayout mKefu;
    private View view;
    private Banner mFragment_banner;
    private RecyclerView mFragment_b_xin_recy;
    //    private RecyclerView mFragment_b_zhang_recy;
    private SwipeRefreshLayout mFragment_shou_ye_swip;
    private ImageView mImageView;
    private String mLink_url;
    private HomePageAdapter mHomePageAdapter;
    public boolean isShow;
    private PreferencesCookieStore cookieStore;
    private SharedPreferencesUtil mSharedPreferences;
    private Object mSession;
    private TextView mFragment_new_tv_more;
    private TextView mTv_content;
    private ProgressBar mFragment_news_progressbar;
    private Dialog mDialog;
    private LinearLayout mFragment_lin_marker;
    private FuturesListInfo mFuturesListInfo;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_web, null);
        unbinder = ButterKnife.bind(this, view);

        mSharedPreferences = SharedPreferencesUtil.getSharedPreferences(getActivity());
        cookieStore = CookieTool.getCookieStore(cxt, mSharedPreferences);

        PermissionUtils.verifyStoragePermissions(getActivity());
        initView();
        if (mFragment_shou_ye_swip != null) {
            mFragment_shou_ye_swip.setRefreshing(true);
        }

        initListener();
        getSession();
        getVersion();
        getBannerInfo();
        getGongGao();
        getMakeListInfo();
        token = sp.getString(Config.TOKEN, null);


        return view;
    }


    private void getVersion() {
        final RequestParams params = new RequestParams();
        params.addQueryStringParameter("version", Config.VERSION);
        params.addQueryStringParameter("myclient", "android");


        OkGo.<String>get(Config.URL_VERSION).execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {
                String result = response.body();
                try {
                    JSONObject jsonObject = new JSONObject(result);

                    if ("1".equals(jsonObject.getString(Config.KEY_CODE))) {
                        Gson gson = new Gson();
                        VersionInfo versionInfo = gson.fromJson(result, VersionInfo.class);
                        String myversion = Tools.getVersion(cxt);
                        String version = versionInfo.getData().getAndroid().getVersion();
                        Double myversionApk = Double.valueOf(myversion);
                        Double versionApk = Double.valueOf(version);

                        if (versionApk > myversionApk) {
                            String url = "";
                            String new_pakage = versionInfo.getData().getAndroid().getNew_pakage();
                            if (new_pakage.contains("http")) {

                                showToLoadDialog(new_pakage);

                            } else {

                                url = Config.URL + new_pakage;
                                showToLoadDialog(url);
                            }
                        }
                    } else {
                        Toast.makeText(cxt, jsonObject.getString("info"), Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {

                    e.printStackTrace();

                }
            }
        });
    }


    private void getGongGao() {

        String lang = "";
        boolean isEngilsh = mSharedPreferences.getBoolean("isEngilsh", false);
        if (isEngilsh) {
            lang = "en";
        } else {
            lang = "zh_cn";
        }


        int num = (int) ((Math.random() * 9 + 1) * 100000);
        OkGo.<String>get(new Config().GONG_GAO + "?rnd=" + String.valueOf(num) + "&lang=" + lang).execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {

                Log.i("qwkuhfiqwuf", response.body());

                mFragment_shou_ye_swip.setRefreshing(false);
                try {
                    JSONObject jsonObject = new JSONObject(response.body());
                    if (jsonObject.getString(Config.KEY_CODE).equals("1")) {

                        String result = response.body();
                        Gson gson = new Gson();
                        GongGao bannerBean = gson.fromJson(result, GongGao.class);
                        setGongGao(bannerBean);
                    }
                } catch (JSONException e) {
                    e.printStackTrace();

                }

            }
        });

//        RequestParams params = new RequestParams();
//        params.addQueryStringParameter("lang", lang);
//        params.addQueryStringParameter("myclient", "android");
//        new HttpUtils().send(HttpRequest.HttpMethod.GET, Config.GONG_GAO + "?rnd=" + String.valueOf(num) + "&lang=" + lang + "&myclient=android", new RequestCallBack<String>() {
//            @Override
//            public void onSuccess(ResponseInfo<String> responseInfo) {
//
//                Log.i("qwkuhfiqwuf", responseInfo.result);
//
//                mFragment_shou_ye_swip.setRefreshing(false);
//                try {
//                    JSONObject jsonObject = new JSONObject(responseInfo.result);
//                    if (jsonObject.getString(Config.KEY_CODE).equals("1")) {
//
//                        String result = responseInfo.result.toString();
//                        Gson gson = new Gson();
//                        GongGao bannerBean = gson.fromJson(result, GongGao.class);
//                        setGongGao(bannerBean);
//                    }
//                } catch (JSONException e) {
//                    e.printStackTrace();
//
//                }
//
//
//            }
//
//            @Override
//            public void onFailure(HttpException error, String msg) {
//
//            }
//        });

    }

    private void setGongGao(GongGao gongGao) {

        if (mFragmentWebTv != null) {
            mFragmentWebTv.setText(gongGao.getData().getGonggao());
        }

        mLink_url = gongGao.getData().getLink_url();

    }

    private void initListener() {
        mFragment_shou_ye_swip.setOnRefreshListener(this);


        mJiaoyiChangwai.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intentc = new Intent(getActivity(), OTCActivity.class);
                startActivity(intentc);
            }
        });

        mFanli.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intentwa = new Intent(cxt, WebActivity.class);
                intentwa.putExtra("web_url", Config.URL + "pub/invite/help");
                startActivity(intentwa);
            }
        });

        mBangzhuCenter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intentc = new Intent(getActivity(), WebActivity.class);
                intentc.putExtra("web_url", Config.URL + "news/index/help");
                startActivity(intentc);
            }
        });

        mKefu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intentc = new Intent(getActivity(), WebActivity.class);
                intentc.putExtra("web_url", Config.URL + "pub/helpdesk");
                startActivity(intentc);
            }
        });
    }

    private void initRrcyData() {

        mHomePageAdapter = new HomePageAdapter(null);
        mFragment_b_xin_recy.setLayoutManager(new LinearLayoutManager(getActivity()));
        mFragment_b_xin_recy.setAdapter(mHomePageAdapter);

        mHomePageAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

                NewBiInfo.DataBean o = (NewBiInfo.DataBean) adapter.getData().get(position);
                Intent intent = new Intent(getActivity(), TradeActivity.class);
                intent.putExtra("pair", o.getPair());
                startActivity(intent);


            }
        });


        mHomePageAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

                NewBiInfo.DataBean o = (NewBiInfo.DataBean) adapter.getData().get(position);
                Intent intent = new Intent(getActivity(), TradeActivity.class);
                intent.putExtra("pair", o.getPair());
                startActivity(intent);

            }
        });

    }

    private void initBanner(BannerBean bannerBean) {

        final ArrayList<String> strings = new ArrayList<>();

        final List<BannerBean.DataBean> data = bannerBean.getData();
        for (int i = 0; i < data.size(); i++) {
            strings.add(data.get(i).getImg());
        }

        //设置图片加载器
        mFragment_banner.setImageLoader(new GlideImageLoader());
        //设置图片集合
        mFragment_banner.setImages(strings);
        mFragment_banner.setDelayTime(8000);

        mFragment_banner.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(int position) {
                String link_url = data.get(position).getLink_url();
                if (link_url != "") {
                    Intent intent = new Intent(getActivity(), WebActivity.class);
                    intent.putExtra("web_url", link_url);
                    startActivity(intent);
                }


            }
        });

        //banner设置方法全部调用完毕时最后调用
        mFragment_banner.start();
    }

    private void initView() {

        LinearLayout fragment_new_tv_me_bt = (LinearLayout) view.findViewById(R.id.fragment_lin_bt);
        mFragment_lin_marker = (LinearLayout) view.findViewById(R.id.fragment_lin_marker);
        mFragment_new_tv_more = (TextView) view.findViewById(R.id.fragment_new_tv_more);
        mFragment_shou_ye_swip = (SwipeRefreshLayout) view.findViewById(R.id.fragment_shou_ye_swip);
        mFragment_banner = (Banner) view.findViewById(R.id.fragment_banner);
        mFragment_b_xin_recy = (RecyclerView) view.findViewById(R.id.fragment_b_xin_recy);

        mImageView = (ImageView) view.findViewById(R.id.fragment_web_imag);
        mFragment_shou_ye_swip.setColorSchemeResources(R.color.swip);
        Glide.with(getActivity()).load(R.mipmap.shouchang).into(mImageView);
        mFragment_b_xin_recy.setNestedScrollingEnabled(false);


        fragment_new_tv_me_bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                Intent intent = new Intent(getActivity(), WebActivity.class);
                intent.putExtra("web_url", "https://btex.me/pub/bt_introduce_m");
                startActivity(intent);

//                Intent intent = new Intent(getActivity(), OTCActivity.class);
//                startActivity(intent);


            }
        });
        mFragment_new_tv_more.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


                Intent intent = new Intent(getActivity(), WebActivity.class);
                intent.putExtra("web_url", "https://btex.me/news/index/ann");
                startActivity(intent);

            }

        });

        mFragment_lin_marker.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(getActivity(), WebActivity.class);
                intent.putExtra("web_url", "https://btex.me/pub/return_fees_by_day");
                startActivity(intent);

            }
        });
    }


    @Override
    public void setData() {


    }

    @Override
    public void onResume() {
        super.onResume();

        handler.removeCallbacks(runnable);
        handler.postDelayed(runnable, 0);


    }

    @Override
    public void onPause() {
        super.onPause();

    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);

        if (isVisibleToUser) {
            isShow = true;

        } else {
            isShow = false;
        }


    }

    @Override
    public void onRefresh() {
        getBannerInfo();
        getGongGao();
//        getNewBi();
//        getNewBiz();
        getMakeListInfo();
//        getFuturesInfo();
    }


    private void getBannerInfo() {
        int num = (int) ((Math.random() * 9 + 1) * 100000);

        OkGo.<String>get(new Config().URL_ADVERT_ONE + "rnd=" + String.valueOf(num)).params("position", "index_banner").execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {
                String result = response.body().toString();
                if (mFragment_shou_ye_swip != null) {
                    mFragment_shou_ye_swip.setRefreshing(false);
                }

                Log.i("dqwokdpqowdoqw", result);
                try {
                    JSONObject jsonObject = new JSONObject(result);
                    String data = jsonObject.getString(Config.KEY_CODE);
                    if (data.equals("1")) {
                        Gson gson = new Gson();
                        BannerBean bannerBean = gson.fromJson(result, BannerBean.class);
                        initBanner(bannerBean);

                    } else {

                    }

                } catch (JSONException e) {
                    e.printStackTrace();

                }
            }
        });


//        String lang = "";
//        boolean isEngilsh = mSharedPreferences.getBoolean("isEngilsh", false);
//        if (isEngilsh) {
//            lang = "en";
//        } else {
//            lang = "zh_cn";
//        }

//        final HttpUtils http = new HttpUtils();
//        RequestParams params = new RequestParams();
//        params.addHeader("channel", MyApplication.mApp.getApplicationMetaData("CXD_CHANNEL_ID"));
//        params.addHeader("app-version", Config.VERSION);
//        params.addHeader("my-client", "android");
//        params.addHeader("lang", lang);
//        params.addQueryStringParameter("position", "index_banner");
//        params.addQueryStringParameter("lang", lang);
//
//
//        http.send(HttpRequest.HttpMethod.GET, Config.URL_ADVERT_ONE + "rnd=" + String.valueOf(num), params, new RequestCallBack<String>() {
//            @Override
//            public void onSuccess(ResponseInfo<String> responseInfo) {
//                mFragment_shou_ye_swip.setRefreshing(false);
//                String result = responseInfo.result.toString();
//                Log.i("dqwokdpqowdoqw", result);
//                try {
//                    JSONObject jsonObject = new JSONObject(result);
//                    String data = jsonObject.getString(Config.KEY_CODE);
//                    if (data.equals("1")) {
//                        Gson gson = new Gson();
//                        BannerBean bannerBean = gson.fromJson(result, BannerBean.class);
//                        initBanner(bannerBean);
//
//                    } else {
//
//                    }
//
//                } catch (JSONException e) {
//                    e.printStackTrace();
//
//                }
//
//            }
//
//            @Override
//            public void onFailure(HttpException error, String msg) {
//
//            }
//        });
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick(R.id.fragment_web_tv)
    public void onViewClicked() {
        if (!TextUtils.isEmpty(mLink_url)) {
            Intent intent = new Intent(getActivity(), WebActivity.class);
            intent.putExtra("web_url", mLink_url);
            startActivity(intent);
        }
    }


    private Handler handler = new Handler() {

    };
    private Runnable runnable = new Runnable() {
        @Override
        public void run() {

            if (isShow) {
//                getBannerInfo();
//                getFuturesInfo();
                getMakeListInfo();
                getGongGao();
//                getNewBi();
//                getNewBiz();

            }

            handler.postDelayed(this, 10000);

        }
    };


    private void showToLoadDialog(final String url) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_version_update, null);
        mDialog = new Dialog(getActivity());
        mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        mDialog.setCancelable(false);// 是否用“返回键”取消
        mDialog.setCanceledOnTouchOutside(false);
        mDialog.setContentView(view);
        mTv_content = (TextView) view.findViewById(R.id.tv_dialog_content);
        TextView tv_confirm = (TextView) view.findViewById(R.id.tv_confirm);
        TextView tv_cancel = (TextView) view.findViewById(R.id.tv_cancel);
        mFragment_news_progressbar = (ProgressBar) view.findViewById(R.id.fragment_news_progressbar);
        mTv_content.setText(getString(R.string.upstring));
        tv_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {

                Uri uris = Uri.parse(url);
                Intent browser = new Intent(Intent.ACTION_VIEW, uris);
                browser.setData(uris);
                browser.addCategory("android.intent.category.BROWSABLE");
                startActivity(browser);

//                toDownload(url);
                mDialog.dismiss();


            }
        });
        tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                mDialog.dismiss();

            }
        });
        // 弹出
        mDialog.show();
    }

    public void getSession() {


        int num = (int) ((Math.random() * 9 + 1) * 30000);


        final HttpUtils http = new HttpUtils();
        RequestParams params = new RequestParams();
        params.addBodyParameter("myclient", "android");
        params.addHeader("myclient", "android");
        params.addQueryStringParameter("position", "index_banner");
//        params.addQueryStringParameter("myclient", "android");

        http.send(HttpRequest.HttpMethod.GET, Config.URL_ADVERT_ONE + "?rnd=" + String.valueOf(num), params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {

                String result = responseInfo.result.toString();

                Log.i("wekfhkweuhf", result);

                mFragment_shou_ye_swip.setRefreshing(false);
                DefaultHttpClient defaultHttpClient = (DefaultHttpClient) http.getHttpClient();

                CookieStore cookieStore = defaultHttpClient.getCookieStore();
                List<Cookie> cookies = cookieStore.getCookies();

//                获取cookie id
                for (Cookie cookie : cookies) {
                    String name = cookie.getName();

                    if ("SESSID".equals(name)) {
                        String value = cookie.getValue();
                        mSharedPreferences.putString(Config.COOKIE, value);
                    }
                }


                try {
                    JSONObject jsonObject = new JSONObject(result);

                    String data = jsonObject.getString(Config.KEY_CODE);

                    if ("1".equals(data)) {
                        Gson gson = new Gson();
                        BannerBean bannerBean = gson.fromJson(result, BannerBean.class);
                        initBanner(bannerBean);
                    }


                } catch (JSONException e) {
                    e.printStackTrace();

                }

            }

            @Override
            public void onFailure(HttpException error, String msg) {
            }
        });
    }

    public void getMakeListInfo() {
        int num = (int) ((Math.random() * 9 + 1) * 100000);
        OkGo.<String>get(Config.GET_MARKET_LISTS + "?rnd=" + String.valueOf(num)).params("return_format", "2").execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {

                String result = response.body().toString();

                Log.i("wkejhfwkejhfkwehfkwehf", result);


                try {
                    JSONObject jsonObject = new JSONObject(result);
                    if (jsonObject.getString(Config.KEY_CODE).equals("1")) {
                        Gson gson = new Gson();
                        BiBiListInfo biBiListInfo = gson.fromJson(result, BiBiListInfo.class);
                        List<BiBiListInfo.DataBean> data = biBiListInfo.getData();
                        if (data.size() > 0) {
                            BiBiListAdapter biBiListAdapter = new BiBiListAdapter(null);
                            mFragment_b_xin_recy.setLayoutManager(new LinearLayoutManager(getActivity()));
                            mFragment_b_xin_recy.setAdapter(biBiListAdapter);
                            biBiListAdapter.setNewData(data);
                            biBiListAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                                @Override
                                public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                                    BiBiListInfo.DataBean o = (BiBiListInfo.DataBean) adapter.getData().get(position);
                                    Intent intent = new Intent(getActivity(), TradeActivity.class);
                                    intent.putExtra("pair", o.getPair());
                                    startActivity(intent);
                                }
                            });
                        }

                    }

                } catch (JSONException e) {
                    e.printStackTrace();

                }
            }
        });


//        SharedPreferencesUtil sp = SharedPreferencesUtil.getSharedPreferences(getActivity());
//        PreferencesCookieStore cookieStore = CookieTool.getCookieStore(getActivity(), sp);
//        RequestParams params = new RequestParams();
//        params.addQueryStringParameter("return_format", "2");
//        new HttpUtils().configCookieStore(cookieStore).send(HttpRequest.HttpMethod.GET, Config.GET_MARKET_LISTS + "?rnd=" + String.valueOf(num), params, new RequestCallBack<String>() {
//            @Override
//            public void onSuccess(ResponseInfo<String> responseInfo) {
//
//                String result = responseInfo.result;
//                Log.i("juvruergqueghkrabegr", result);
//
//                try {
//                    JSONObject jsonObject = new JSONObject(responseInfo.result);
//                    if (jsonObject.getString(Config.KEY_CODE).equals("1")) {
//                        Gson gson = new Gson();
//                        BiBiListInfo biBiListInfo = gson.fromJson(responseInfo.result, BiBiListInfo.class);
//                        List<BiBiListInfo.DataBean> data = biBiListInfo.getData();
//                        if (data.size() > 0) {
//                            BiBiListAdapter biBiListAdapter = new BiBiListAdapter(null);
//                            mFragment_b_xin_recy.setLayoutManager(new LinearLayoutManager(getActivity()));
//                            mFragment_b_xin_recy.setAdapter(biBiListAdapter);
//                            biBiListAdapter.setNewData(data);
//                            biBiListAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
//                                @Override
//                                public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
//                                    BiBiListInfo.DataBean o = (BiBiListInfo.DataBean) adapter.getData().get(position);
//                                    Intent intent = new Intent(getActivity(), TradeActivity.class);
//                                    intent.putExtra("pair", o.getPair());
//                                    startActivity(intent);
//                                }
//                            });
//                        }
//
//
//                    }
//
//                } catch (JSONException e) {
//                    e.printStackTrace();
//
//                }
//
//
//            }
//
//            @Override
//            public void onFailure(HttpException error, String msg) {
//
//
//            }
//        });

    }

}
